package com.cakemallproject.service.impl;

import com.cakemallproject.mapper.RecommendMapper;
import com.cakemallproject.pojo.mapperObj.Recommend;
import com.cakemallproject.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecommendServiceImpl implements RecommendService {
    @Autowired
    private RecommendMapper recommendMapper;
    @Override
    public List<Recommend> list() {
        return recommendMapper.list();
    }

    @Override
    public void insert(List<Integer> ids) {
        for (Integer gid : ids) {
            Recommend r = recommendMapper.getByGid(gid);
            System.out.println("r = " + r);
            if (r == null) {
                recommendMapper.insert(gid);
            }
        }
    }

    @Override
    public void delete(List<Integer> ids) {
        recommendMapper.delete(ids);
    }
}
